<!DOCTYPE>
<html lang="en">

<head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no,user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
    <meta name="theme-color" content="#000000"/>
    <meta name="x5-fullscreen" content="true">
    <meta name="mobile-web-app-capable" content="yes">
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="Cache-control" content="no-cache">
    <title>智能交互</title>
    <style>
      .select-text {
        -webkit-user-select: text;
        -moz-user-select: text;
        -ms-user-select: text;
        user-select: text;
      }

      .box {
        display: flex;
        flex-wrap: wrap;
        flex-direction: row;
        justify-content: space-around;
        background: center / contain repeat url(https://www.huaweicloud.com/content/dam/cloudbu-site/archive/china/zh-cn/product/cloud_communications/meeting/image/image-%E5%B8%AE%E5%8A%A9%E6%96%87%E6%A1%A3-2.png);
      }

    </style>
</head>

<body>
<div class="box" style="display: flex; display: -webkit-flex; ">
    <div id="ics-sdk" style="width: 100vw;height: 100vh">
    </div>
</div>
</body>
<script src="https://cdn.bootcss.com/vConsole/3.3.4/vconsole.min.js"></script>
<script>
    // 初始化
    var vConsole = new VConsole();
</script>


<script>
<!--    测试浏览器是否具有navigator-->
       navigator.getUserMedia  = navigator.getUserMedia ||
                             navigator.webkitGetUserMedia ||
                             navigator.mozGetUserMedia ||
                             navigator.msGetUserMedia;

   if (navigator.getUserMedia) {
          console.log("支持navigator")
   } else {
          console.log("不支持navigator")
   }

</script>

<script src="./HwICSUiSdk.js"></script>
<link rel="stylesheet" href="./HwICSUiSdk.css">

<script>
    async function inspect() {
        const result = await HwICSUiSdk.checkBrowserSupport();
    if (result) {
        console.log("支持SDK")
    } else {
      console.log("不支持SDK")
    }
     }
    inspect()
</script>

<script>
    var isReady = false
    let text = ''
</script>

<script>
    <!--    华北-北京四：metastudio-api.cn-north-4.myhuaweicloud.com-->
    <!--    华东-上海一：metastudio-api.cn-east-3.myhuaweicloud.com-->

            HwICSUiSdk.create({
              serverAddress: 'https://1.94.138.6/icswebclient?robot_id=8a80862f92e27dfc0193058db6ea020d',
              onceCode: 'Zg2UdVQM9NwH1drMuZWJmI8GsTBHwHf6hBAgbcQkcQX6GdXD2mD92bgBugt4roYj',
              robotId: '8a80862f92e27dfc0193058db6ea020d',
              containerId: 'ics-sdk',
            });

</script>

<script>
    HwICSUiSdk.setConfig({
      enableCaption: true,
      enableChatBtn: true,
      enableHotIssues: true,
      enableWeakErrorInfo: true,
    });
</script>

<script>
    //事件回调
    HwICSUiSdk.addEventListeners({
       speakingStart: () =>{
         console.log('speakingStart');
        },
       speakingStop: () => {
         window.harmony.evaluateDialog();
         console.log('speakingStop');
       },
       jobInfoChange: (jobInfo) => {
       this.isReady = jobInfo.isReady
        console.log('jobInfoChange', jobInfo);
       },
       speechRecognized: (question) => { //语音识别事件
         this.text = question.text
         console.log('speechRecognized', question);

       }
 });
</script>

<script>
    function htmlTest() {
        console.log('JavaScript Hello World!: ', this.isReady);
        return this.text
    }
</script>

</html>
